﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Web.Mvc;
using Kendo.Mvc;
using Kendo.Mvc.Infrastructure;
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
using SecurityApi.DataAccess;
using SecurityApi.Business;

namespace SecurityAdmin.Web.Controllers
{
    public class EnterpriseController : BaseController
    {
        //
        // GET: /Enterprise/

        public ActionResult SelectEnterprise()
        {
            return View();
        }

        public ActionResult ChangeSelection()
        {
            return View();
        }

        public ActionResult EnterpriseSelected()
        {
            return View();
        }

        public ActionResult AjaxGetAllEnterprises([DataSourceRequest] DataSourceRequest request)
        {
            EnterpriseManager mgr = new EnterpriseManager();
            IQueryable<SecurityApi.Model.Enterprise> apps = mgr.GetAllEnterprises();
            return Json(apps.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
        }

        public ActionResult MakeDefaultEnterprise(int enterpriseId)
        {
            EnterpriseManager mgr = new EnterpriseManager();
            SecurityApi.Model.Enterprise enterprise = mgr.GetEnterpriseById(enterpriseId);
            SetCurrentEnterprise(enterprise);
            return RedirectToAction("EnterpriseSelected");
        }


    }
}
